﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.quest.Display.QuestManager {
    import flash.events.*;
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import __AS3__.vec.*;
    import Modules.quest.Managers.*;
    import Display.*;
    import org.aswing.ext.*;
    import Display.aswingui.*;

    public class QuestManagerCell extends JPanel implements GridListCell {

        public static const CELL_WIDTH:int = 74;
        public static const CELL_HEIGHT:int = 74;

        protected var m_gridList:GridList;
        protected var m_index:int;
        protected var m_questIcon:GameSprite;
        protected var m_panel:JPanel;

        public function QuestManagerCell(_arg1:LayoutManager=null){
            super(_arg1);
            ASwingHelper.prepare(this);
        }
        public function setGridListCellStatus(_arg1:GridList, _arg2:Boolean, _arg3:int):void{
            if (_arg1){
                this.m_gridList = _arg1;
                this.m_index = _arg3;
                _arg1.setTileWidth(this.getPreferredWidth());
                _arg1.setTileHeight(this.getPreferredHeight());
            };
        }
        public function setCellValue(_arg1):void{
            this.m_questIcon = _arg1;
            this.initializeCell();
            this.setGridListCellStatus(this.m_gridList, false, this.m_index);
        }
        public function getCellValue(){
            return (this.m_questIcon);
        }
        public function getCellComponent():Component{
            return (this);
        }
        protected function initializeCell():void{
            var _local1:AssetPane = new AssetPane(this.m_questIcon);
            this.m_panel = new JPanel(new BorderLayout());
            this.m_panel.append(_local1, BorderLayout.CENTER);
            ASwingHelper.prepare(this.m_panel);
            this.append(this.m_panel);
            ASwingHelper.prepare(this);
            this.setPreferredWidth(CELL_WIDTH);
            this.setPreferredHeight(CELL_HEIGHT);
            this.addEventListener(MouseEvent.ROLL_OVER, this.onRollOver, false, 0, true);
            this.addEventListener(MouseEvent.ROLL_OUT, this.onRollOut, false, 0, true);
        }
        protected function buildToolTip():Boolean{
            var _local2:Quest;
            var _local3:GameQuest;
            var _local1:Vector.<Quest> = Global.questManager.getActiveQuests();
            for each (_local2 in _local1) {
                if ((((_local2 is GameQuest)) && ((_local2.name == this.m_questIcon.name)))){
                    _local3 = (_local2 as GameQuest);
                    if ((((_local3.tasks.length == 1)) && ((((_local3.tasks[0].action == "seenQuest")) || ((_local3.tasks[0].action == "popNews")))))){
                        return (false);
                    };
                    UI.questManagerView.content.questToolTip.initializeToolTip(ZLoc.t("Quest", (this.m_questIcon.name + "_dialog_title")), _local3.getProgressStrings(), _local3.getRewardsData());
                };
            };
            return (true);
        }
        protected function makeBackground():void{
            var _local1:DisplayObject = (new (QuestManagerView.assetDict["questManagerCellBG"])() as DisplayObject);
            var _local2:MarginBackground = new MarginBackground(_local1);
            this.setBackgroundDecorator(_local2);
        }
        protected function removeBackground():void{
            this.setBackgroundDecorator(null);
        }
        protected function onRollOver(_arg1:MouseEvent):void{
            if (this.buildToolTip()){
                UI.questManagerView.content.questToolTip.visible = true;
            };
            this.makeBackground();
        }
        protected function onRollOut(_arg1:MouseEvent):void{
            UI.questManagerView.content.questToolTip.visible = false;
            this.removeBackground();
        }

    }
}//package Modules.quest.Display.QuestManager 
